<?php
/**
* A unique identifier is defined to store the options in the database and reference them from the theme.
* By default it uses the theme name, in lowercase and without spaces, but this can be changed if needed.
* If the identifier changes, it'll appear as if the options have been reset.
*
*/

function optionsframework_option_name() {

	// This gets the theme name from the stylesheet (lowercase and without spaces)
	$themename = wp_get_theme('style.css');
	$themename = $themename['Name'];
	$themename = preg_replace("/\W/", "", strtolower($themename) );

	$optionsframework_settings = get_option('optionsframework');
	$optionsframework_settings['id'] = $themename;
	update_option('optionsframework', $optionsframework_settings);

	// echo $themename;
}

/**
* Defines an array of options that will be used to generate the settings page and be saved in the database.
* When creating the "id" fields, make sure to use all lowercase and no spaces.
*
*/

function optionsframework_options() {

	// Pull all the categories into an array
	$options_categories = array();
	$options_categories_obj = get_categories();
	foreach ($options_categories_obj as $category) {
		$options_categories[$category->cat_ID] = $category->cat_name;
	}

	// Add all categories option
	$options_categories[0] = __("All Categories", 'vnnews');

	/*// Pull all the pages into an array
	$options_pages = array();
	$options_pages_obj = get_pages('sort_column=post_parent,menu_order');
	$options_pages['false'] = __("Select a page:", 'vnnews');
	foreach ($options_pages_obj as $page) {
		$options_pages[$page->ID] = $page->post_title;
	}*/

	//Pull all the advertisement categories into array
	$args = array(
	'type'                     => 'advertise',
	'orderby'                  => 'name',
	'order'                    => 'ASC',
	'taxonomy'                 => 'adv_categories',
	);

	$options_ads_categories = array();
	$options_ads_categories_obj = get_categories( $args );
	foreach ($options_ads_categories_obj as $adv_category) {
		$options_ads_categories[$adv_category->cat_ID] = $adv_category->cat_name;
	}
	$options_ads_categories[0] = __("All Categories", 'vnnews');

	//Define Type of view for Featured Category
	$options_view = array();
	$options_view[5] = __('5 post (1 on left, 4 on right)','vnnews');
	$options_view[52] = __('5 post (4 on left, 1 on right)','vnnews');
	$options_view[6] = __('6 post (3 on left, 3 on right)','vnnews');
	$options_view[8] = __('8 post (4 on left, 4 on right)','vnnews');
	$options_view[10] = __('10 post (5 on left, 5 on right)','vnnews');
	$options_view[12] = __('12 post (6 on left, 6 on right)','vnnews');

	//Define type of slider effect
	$options_effect = array();
	$options_effect[0] = __('fade', 'vnnews');
	$options_effect[1] = __('slide', 'vnnews');

	//Define type of slider direction\
	$options_direction = array();
	$options_direction[0] = __('horizontal', 'vnnews');
	$options_direction[1] = __('vertical', 'vnnews');

	// If using image radio buttons, define a directory path
	$imagepath =  get_stylesheet_directory_uri() . '/images/';

	$options = array();

	//***************************************************************************************//
	//		Home Page
	//***************************************************************************************//
	$options[] = array( "name" => __("Homepage", 'vnnews'),
						"type" => "heading");

		//------------------News Slider HomePage-----------------------------

		$options[] = array( "name" => __("News Slider Homepage", 'vnnews'),
							"desc" => __("", 'vnnews'),
							"id" => "news_slider_homepage",
							"std" => __("", 'vnnews'),
							"type" => "info");

		$options[] = array( "name" => __("Enable News Slider Homepage?", 'vnnews'),
							"desc" => __("Check to enable news slider on homepage.", 'vnnews'),
							"id" => "enable_news_slider",
							"std" => "1",
							"type" => "checkbox");

		$options[] = array( "name" => __("Slider category", 'vnnews'),
							"desc" => __("Select the slider category, select <strong><i>none</i></strong> to display lastest post", 'vnnews'),
							"id" => "news_slider_category",
							"std" => __("Select a category:", 'vnnews'),
							"type" => "select",
							"options" => $options_categories);

		$options[] = array( "name" => __("Number of news", 'vnnews'),
							"desc" => __("Number of news shows in slider", 'vnnews'),
							"id" => "news_slider_numberpost",
							"std" => "5",
							"type" => "text");

		$options[] = array( "name" => __("Slider Speed", 'vnnews'),
							"desc" => __("Timer to change slide (config is milliseconds : 1000 ms = 1s)", 'vnnews'),
							"id" => "news_slider_speed",
							"std" => "7000",
							"type" => "text");

		$options[] = array( "name" => __("Slider Effect", 'vnnews'),
							"desc" => __("", 'vnnews'),
							"id" => "news_slider_transition",
							"std" => "Select a value",
							"type" => "select",
							"options" => $options_effect);

		$options[] = array( "name" => __("Slider Direction", 'vnnews'),
							"desc" => __("Apply for Slider Effect is Slide", 'vnnews'),
							"id" => "news_slider_direction",
							"std" => "Select a value",
							"type" => "select",
							"options" => $options_direction);

		//------------------Single Column------------------------------------

		$options[] = array( "name" => __("Single Column Categories", 'vnnews'),
								"desc" => __("", 'vnnews'),
								"id" => "single_column_categories",
								"std" => __("", 'vnnews'),
								"type" => "info");

		$options[] = array( "name" => __("Enable Categories?", 'vnnews'),
							"desc" => __("Check to enable single column on homepage.", 'vnnews'),
							"id" => "enable_single_column",
							"std" => "1",
							"type" => "checkbox");

		$options[] = array( "name" => __("Left Column Category", 'vnnews'),
								"desc" => __("Select the first category, select <strong><i>none</i></strong> to display lastest post", 'vnnews'),
								"id" => "left_column_category",
								"std" => __("Select a category:", 'vnnews'),
								"type" => "select",
								"options" => $options_categories);

		$options[] = array( "name" => __("Right Column Category", 'vnnews'),
								"desc" => __("Select the second category, select <strong><i>none</i></strong> to display lastest post", 'vnnews'),
								"id" => "right_column_category",
								"std" => __("Select a category:", 'vnnews'),
								"type" => "select",
								"options" => $options_categories);


		//------------------Featured Categories -------------------------------------

		$options[] = array( "name" => __("Featured Categories", 'vnnews'),
								"desc" => __("", 'vnnews'),
								"id" => "featured_categories",
								"std" => __("", 'vnnews'),
								"type" => "info");

		$options[] = array( "name" => __("Enable Featured Categories?", 'vnnews'),
							"desc" => __("Check to enable featured categories section on homepage.", 'vnnews'),
							"id" => "enable_featured_categories",
							"std" => "1",
							"type" => "checkbox");

		$options[] = array( "name" => __("Featured Category 1", 'vnnews'),
								"desc" => __("Select the first category, select <strong><i>none</i></strong> to disable", 'vnnews'),
								"id" => "featured_category_1",
								"std" => __("Select a category:", 'vnnews'),
								"type" => "select",
								"options" => $options_categories);

		$options[] = array( "name" => __("View type of Featured Category 1", 'vnnews'),
								"desc" => __("Select 5 post (1 on left, 4 on right) or 6 post (3 on left, 3 on right) ", 'vnnews'),
								"id" => "view_type_featured_category_1",
								"std" => __("Select view type:", 'vnnews'),
								"type" => "select",
								"options" => $options_view);

		$options[] = array( "name" => __("", 'vnnews'),
								"desc" => __("", 'vnnews'),
								"id" => "featured_categories",
								"std" => __("", 'vnnews'),
								"type" => "info");

		$options[] = array( "name" => __("Featured Category 2", 'vnnews'),
								"desc" => __("Select the second category, select <strong><i>none</i></strong> to disable", 'vnnews'),
								"id" => "featured_category_2",
								"std" => __("Select a category:", 'vnnews'),
								"type" => "select",
								"options" => $options_categories);

		$options[] = array( "name" => __("View type of Featured Category 2", 'vnnews'),
								"desc" => __("Select 5 post (1 on left, 4 on right) or 6 post (3 on left, 3 on right) ", 'vnnews'),
								"id" => "view_type_featured_category_2",
								"std" => __("Select view type:", 'vnnews'),
								"type" => "select",
								"options" => $options_view);

		$options[] = array( "name" => __("", 'vnnews'),
								"desc" => __("", 'vnnews'),
								"id" => "featured_categories",
								"std" => __("", 'vnnews'),
								"type" => "info");

		$options[] = array( "name" => __("Featured Category 3", 'vnnews'),
								"desc" => __("Select the third category, select <strong><i>none</i></strong> to disable", 'vnnews'),
								"id" => "featured_category_3",
								"std" => __("Select a category:", 'vnnews'),
								"type" => "select",
								"options" => $options_categories);

		$options[] = array( "name" => __("View type of Featured Category 3", 'vnnews'),
								"desc" => __("Select 5 post (1 on left, 4 on right) or 6 post (3 on left, 3 on right) ", 'vnnews'),
								"id" => "view_type_featured_category_3",
								"std" => __("Select view type:", 'vnnews'),
								"type" => "select",
								"options" => $options_view);

		$options[] = array( "name" => __("", 'vnnews'),
								"desc" => __("", 'vnnews'),
								"id" => "featured_categories",
								"std" => __("", 'vnnews'),
								"type" => "info");

		$options[] = array( "name" => __("Featured Category 4", 'vnnews'),
								"desc" => __("Select the fourth category, select <strong><i>none</i></strong> to disable", 'vnnews'),
								"id" => "featured_category_4",
								"std" => __("Select a category:", 'vnnews'),
								"type" => "select",
								"options" => $options_categories);

		$options[] = array( "name" => __("View type of Featured Category 4", 'vnnews'),
								"desc" => __("Select 5 post (1 on left, 4 on right) or 6 post (3 on left, 3 on right) ", 'vnnews'),
								"id" => "view_type_featured_category_4",
								"std" => __("Select view type:", 'vnnews'),
								"type" => "select",
								"options" => $options_view);

		$options[] = array( "name" => __("", 'vnnews'),
								"desc" => __("", 'vnnews'),
								"id" => "featured_categories",
								"std" => __("", 'vnnews'),
								"type" => "info");

		$options[] = array( "name" => __("Featured Category 5", 'vnnews'),
								"desc" => __("Select the fifth category, select <strong><i>none</i></strong> to disable", 'vnnews'),
								"id" => "featured_category_5",
								"std" => __("Select a category:", 'vnnews'),
								"type" => "select",
								"options" => $options_categories);

		$options[] = array( "name" => __("View type of Featured Category 5", 'vnnews'),
								"desc" => __("Select 5 post (1 on left, 4 on right) or 6 post (3 on left, 3 on right) ", 'vnnews'),
								"id" => "view_type_featured_category_5",
								"std" => __("Select view type:", 'vnnews'),
								"type" => "select",
								"options" => $options_view);

		$options[] = array( "name" => __("", 'vnnews'),
								"desc" => __("", 'vnnews'),
								"id" => "featured_categories",
								"std" => __("", 'vnnews'),
								"type" => "info");

		$options[] = array( "name" => __("Featured Category 6", 'vnnews'),
								"desc" => __("Select the sixth category, select <strong><i>none</i></strong> to disable", 'vnnews'),
								"id" => "featured_category_6",
								"std" => __("Select a category:", 'vnnews'),
								"type" => "select",
								"options" => $options_categories);

		$options[] = array( "name" => __("View type of Featured Category 6", 'vnnews'),
								"desc" => __("Select 5 post (1 on left, 4 on right) or 6 post (3 on left, 3 on right) ", 'vnnews'),
								"id" => "view_type_featured_category_6",
								"std" => __("Select view type:", 'vnnews'),
								"type" => "select",
								"options" => $options_view);


	//***************************************************************************************//
	//		Layout
	//***************************************************************************************//
	$options[] = array( "name" => __("Layout", 'vnnews'),
						"type" => "heading");
		$options[] = array( "name" => __("Upload Logo", 'vnnews'),
							"desc" => __("The logo will display on top head of website.", 'vnnews'),
							"id" => "theme_logo",
							"std" => "",
							"type" => "upload");

		$options[] = array( "name" => __("Upload Favicon", 'vnnews'),
							"desc" => __("The favicon will display on tab of browser.", 'vnnews'),
							"id" => "theme_favicon",
							"std" => "",
							"type" => "upload");

		$options[] = array( "name" => __("Individual post config", 'vnnews'),
								"desc" => __("", 'vnnews'),
								"id" => "individual_post_config",
								"std" => __("", 'vnnews'),
								"type" => "info");

		$options[] = array( "name" => __("Display Post Featured Image or Video?", 'vnnews'),
							"desc" => __("Selecting this option will display the featured image or video in an individual post.", 'vnnews'),
							"id" => "display_feature_post",
							"std" => "1",
							"type" => "checkbox");

		$options[] = array( "name" => __("Enable display related post", 'vnnews'),
							"desc" => __("Selecting this option will display the related post in an individual post.", 'vnnews'),
							"id" => "enable_related_post",
							"std" => "1",
							"type" => "checkbox");

		$options[] = array( "name" => __("Number of related posts", 'vnnews'),
							"desc" => __("Number of posts display on detail post page.", 'vnnews'),
							"id" => "number_related_post",
							"std" => '4',
							"type" => "text");

		$options[] = array( "name" => __("Related post title", 'vnnews'),
							"desc" => __("Heading of related post title.", 'vnnews'),
							"id" => "title_related_post",
							"std" => 'You may also like :',
							"type" => "text");

		$options[] = array( "name" => __("", 'vnnews'),
								"desc" => __("", 'vnnews'),
								"id" => "end_individual_post_config",
								"std" => __("", 'vnnews'),
								"type" => "info");


		$options[] = array( "name" => __("Enable CSS3 Full Width Background Image?", 'vnnews'),
							"desc" => __("Enables an applied background image to stretch to the full width of the browser. Do not use with a tiled background.", 'vnnews'),
							"id" => "background_stretch",
							"std" => "1",
							"type" => "checkbox");

		$options[] = array( "name" => __("Enable Responsive Layout?", 'vnnews'),
							"desc" => __("Enables the responsive site layout for the iPhone, iPad and mobile devices.", 'vnnews'),
							"id" => "enable_responsive",
							"std" => "1",
							"type" => "checkbox");


	//***************************************************************************************//
	//		Social
	//***************************************************************************************//

	$options[] = array( "name" => __("Social", 'vnnews'),
						"type" => "heading");

		$options[] = array( "name" => __("Blog Social Links", 'vnnews'),
							"desc" => __("Selecting this option will display the social links on the blog page template. Disabling this feature may increase the blog load time.", 'vnnews'),
							"id" => "display_social_blog",
							"std" => "1",
							"type" => "checkbox");

		$options[] = array( "name" => __("Post Social Links", 'vnnews'),
							"desc" => __("Selecting this option will display the social links on the individual posts.", 'vnnews'),
							"id" => "display_social_post",
							"std" => "1",
							"type" => "checkbox");

		$options[] = array( "name" => __("Twitter Name", 'vnnews'),
							"desc" => __("Please enter your Twitter username.", 'vnnews'),
							"id" => "twitter_user",
							"std" => '',
							"type" => "text");

		$options[] = array( "name" => __("Facebook Page Link", 'vnnews'),
							"desc" => __("Enter a link to your Facebook page or profile.", 'vnnews'),
							"id" => "facebook_link",
							"std" => "",
							"type" => "text");

		$options[] = array( "name" => __("Twitter Account Link", 'vnnews'),
							"desc" => __("Enter a link to your Twitter account.", 'vnnews'),
							"id" => "twitter_link",
							"std" => "",
							"type" => "text");

		$options[] = array( "name" => __("LinkedIn Account Link", 'vnnews'),
							"desc" => __("Enter a link to your LinkedIn page.", 'vnnews'),
							"id" => "linkedin_link",
							"std" => "",
							"type" => "text");

		$options[] = array( "name" => __("Dribbble Page Link", 'vnnews'),
							"desc" => __("Enter a link to your Dribbble page.", 'vnnews'),
							"id" => "dribbble_link",
							"std" => "",
							"type" => "text");

		$options[] = array( "name" => __("Skype Account Link", 'vnnews'),
							"desc" => __("Enter a link to your Skype account. (e.g. skype://MySkypeName)", 'vnnews'),
							"id" => "skype_link",
							"std" => "",
							"type" => "text");

		$options[] = array( "name" => __("Google Plus Profile Link", 'vnnews'),
							"desc" => __("Enter a link to your Google Plus page.", 'vnnews'),
							"id" => "plus_link",
							"std" => "",
							"type" => "text");

		$options[] = array( "name" => __("Pinterest Profile Link", 'vnnews'),
							"desc" => __("Enter a link to your Pinterest page.", 'vnnews'),
							"id" => "pinterest_link",
							"std" => "",
							"type" => "text");

		$options[] = array( "name" => __("Github Link", 'vnnews'),
							"desc" => __("Enter a link to your Github page.", 'vnnews'),
							"id" => "github_link",
							"std" => "",
							"type" => "text");

		$options[] = array( "name" => __("Instagram Link", 'vnnews'),
							"desc" => __("Enter a link to your Instagram page.", 'vnnews'),
							"id" => "instagram_link",
							"std" => "",
							"type" => "text");

		$options[] = array( "name" => __("YouTube Link", 'vnnews'),
							"desc" => __("Enter a link to your YouTube page.", 'vnnews'),
							"id" => "youtube_link",
							"std" => "",
							"type" => "text");

		$options[] = array( "name" => __("Email Address", 'vnnews'),
							"desc" => __("Enter your email address.", 'vnnews'),
							"id" => "email_link",
							"std" => "",
							"type" => "text");

	//***************************************************************************************//
	//		Advertisements
	//***************************************************************************************//
	$options[] = array( "name" => __("Advertisements", 'vnnews'),
						"type" => "heading");

	$options[] = array( "name" => __("Enable random advertisement in each category?", 'vnnews'),
							"desc" => __("Check to enable random advertisement, none to display lastest advertisement.", 'vnnews'),
							"id" => "enable_advertisement_random",
							"std" => "1",
							"type" => "checkbox");

	$options[] = array( "name" => __("Advertisement in individual post", 'vnnews'),
								"desc" => __("", 'vnnews'),
								"id" => "adv_in_post",
								"std" => __("", 'vnnews'),
								"type" => "info");

	$options[] = array( "name" => __("Enable advertisement on TOP position in post?", 'vnnews'),
							"desc" => __("Check to enable advertisement on top.", 'vnnews'),
							"id" => "enable_adv_top_post",
							"std" => "1",
							"type" => "checkbox");

	$options[] = array(
						'name' => "Choose position of advertisement on top",
						'desc' => "Choose position of advertisement will display on.",
						'id' => "adv_position_top_post",
						'std' => "adv_post_top_left",
						'type' => "images",
						'options' => array(
							'adv_post_top_left' => $imagepath . 'post_top_left.png',
							'adv_post_top_center' => $imagepath . 'post_top_center.png',
							'adv_post_top_right' => $imagepath . 'post_top_right.png')
				);

	$options[] = array( "name" => __("Advertisement category on top", 'vnnews'),
								"desc" => __("Select the advertisement category on top of post, select <strong><i>none</i></strong> to disable", 'vnnews'),
								"id" => "adv_category_top_post",
								"std" => __("Select a category:", 'vnnews'),
								"type" => "select",
								"options" => $options_ads_categories);

	$options[] = array( "name" => __("Enable advertisement on CENTER position in post?", 'vnnews'),
							"desc" => __("Check to enable advertisement on center.", 'vnnews'),
							"id" => "enable_adv_center_post",
							"std" => "0",
							"type" => "checkbox");

	$options[] = array(
						'name' => "Choose position of advertisement on center",
						'desc' => "Choose position of advertisement will display on.",
						'id' => "adv_position_center_post",
						'std' => "adv_post_center_left",
						'type' => "images",
						'options' => array(
							'adv_post_center_left' => $imagepath . 'post_center_left.png',
							'adv_post_center_center' => $imagepath . 'post_center_center.png',
							'adv_post_center_right' => $imagepath . 'post_center_right.png')
				);

	$options[] = array( "name" => __("Advertisement category on center", 'vnnews'),
								"desc" => __("Select the advertisement category on center of post, select <strong><i>none</i></strong> to disable", 'vnnews'),
								"id" => "adv_category_center_post",
								"std" => __("Select a category:", 'vnnews'),
								"type" => "select",
								"options" => $options_ads_categories);

	$options[] = array( "name" => __("Enable advertisement on BOTTOM position in post?", 'vnnews'),
							"desc" => __("Check to enable advertisement on bottom.", 'vnnews'),
							"id" => "enable_adv_bottom_post",
							"std" => "0",
							"type" => "checkbox");

	$options[] = array(
						'name' => "Choose position of advertisement on bottom",
						'desc' => "Choose position of advertisement will display on.",
						'id' => "adv_position_bottom_post",
						'std' => "adv_post_bottom_left",
						'type' => "images",
						'options' => array(
							'adv_post_bottom_left' => $imagepath . 'post_bottom_left.png',
							'adv_post_bottom_center' => $imagepath . 'post_bottom_center.png',
							'adv_post_bottom_right' => $imagepath . 'post_bottom_right.png')
				);

	$options[] = array( "name" => __("Advertisement category on bottom", 'vnnews'),
								"desc" => __("Select the advertisement category on bottom of post, select <strong><i>none</i></strong> to disable", 'vnnews'),
								"id" => "adv_category_bottom_post",
								"std" => __("Select a category:", 'vnnews'),
								"type" => "select",
								"options" => $options_ads_categories);

	//***************************************************************************************//
	//		Others
	//***************************************************************************************//
	$options[] = array( "name" => __("Others", 'vnnews'),
						"type" => "heading");

		$options[] = array( "name" => __("Google Analytics", 'vnnews'),
								"desc" => __("Enter google analytics code.", 'vnnews'),
								"id" => "google_analytics",
								"std" => "",
								"type" => "textarea");

		$options[] = array( "name" => __("Footer", 'vnnews'),
							"desc" => __("Config as Copyright information(support HTML tags)", 'vnnews'),
							"id" => "footer_left",
							"std" => "",
							"type" => "textarea");


	return $options;
}